﻿using BootstrapBlazor.Components;
using BPM.Web.Shared.Data;
using BPM.Web.Shared.Dependencies;
using BPM.Web.Shared.Extensions;
namespace BPM.Web.Shared.Service;

[Scoped(typeof(ISysPosService))]
public class SysPosService : BaseService, ISysPosService
{
    private readonly IPosClient _posClient;
    public SysPosService(IPosClient posClient, ToastService toast) : base(toast)
        => _posClient = posClient;

    public Task<QueryData<SysPos>> PageAsync(PosPageInput input)
        => QueryAsync(_posClient.PageAsync(input));

    public Task<List<SysPos>?> ListAsync(PosInput input)
        => QueryAsync<List<SysPos>>(_posClient.ListAsync(input));

    public Task<bool> AddAsync(SysPos input)
        => ExecuteAsync(_posClient.AddAsync(input.Adapt<AddPosInput>()));

    public Task<bool> DeleteAsync(IEnumerable<SysPos> input)
        => DeleteAsync(input.Adapts<SysPos, DeletePosInput>().Select(x => _posClient.DeleteAsync(x)));

    public Task<bool> EditAsync(SysPos input)
        => ExecuteAsync(_posClient.EditAsync(input.Adapt<UpdatePosInput>()));

    public Task<SysPos?> DetailAsync(QueryPosInput input)
        => QueryAsync(_posClient.DetailAsync(input));
}

